/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Lily
 * Date: 2024-09-26
 * Time: 0:02
 */
public class reverse_List {
    public ListNode reverseList(ListNode head) {
        if (head==null){
            return null;
        }
        return reverseList_do(head);

    }
    public ListNode reverseList_do(ListNode node){
        if (node.next==null){
            System.out.println(node.val);
            return node;
        }

        ListNode newHead=reverseList(node.next);
        node.next.next=node;
        node.next=null;
        System.out.print(node.val);
        return newHead;
    }

    public static void main(String[] args) {

    }
}
